Type GFX_ParticleSystem_VerticalDots Extends GFX_ParticleSystem

	Global vx:Int
	Global vy:Int
	Global vw:Int
	Global vh:Int
	
	Field speedMin:Float = 1.0
	Field speedMax:Float = 3.0
		
	Method setParticles (total:Int, minSpeed:Float = 1.0, maxSpeed:Float = 3.0)
		GetViewport(vx, vy, vw, vh)
		speedMin = minSpeed
		speedMax = maxSpeed
		particles = New GFX_Particle[total]
		For Local i:Int = 0 To particles.length - 1
			particles[i] = New GFX_Particle
			setParticleDefaults(particles[i])
			particles[i].position.setY(particles[i].position.getY() - Rand(0, vh))
		Next		
	End Method

	Method update:Int ()
		GetViewport(vx, vy, vw, vh)
		If particles Then
			For Local p:GFX_Particle = EachIn particles
				p.update()
				If p.position.getY() > vy + vh Then
					setParticleDefaults(p)
				End If
			Next
		End If
		Return True
	End Method
	
	Method setParticleDefaults ( p:GFX_Particle )
		p.energy = 1
		p.position.setXYZ(Rand(vx, vx + vw), vy, 0)
		p.oldPosition.set(p.position)
		p.color.setA(Rand(80, 200))
		p.velocity.setXYZ(0, Rnd(speedMin, speedMax), 0)
	End Method
	
	Method preRender ()
		SetBlend(ALPHABLEND)
	End Method
	
	Method RenderParticle (p:GFX_Particle, tween:Float = 1)
		SetColor(p.color.getR(), p.color.getG(), p.color.getB())
		SetAlpha(p.color.getAFloat())
		DrawOval(p.position.GetInterpolateX(p.oldPosition, tween), p.position.GetInterpolateY(p.oldPosition, tween), 3, 3)
	End Method
	
	Method postRender ()
	End Method

End Type
